package de.tabuma.lib.contentmanagement.entity;

import java.util.*;
import de.tabuma.lib.contentmanagement.*;
import java.lang.reflect.*;

/**
 * <p>Collecting the properties that will be needed to create a formular for an entity.</p>
 * @author $Author: $
 * @version $Revision: $
 * @since $Date: $
 * @see Content
 */
public class FormContent {


    /**
     * Content that has static values
     */
    public StaticContent StaticContent;

    /**
     * Class constructor.
     */
    public FormContent() {
        this.StaticContent = new StaticContent();
        this.entityClass = null;
        this.entityName = "";
        this.displayedName = new Hashtable<Field, String>();
        this.editableFieldTypes = new Vector<Integer>();
        this.editableFields = new Vector<Field>();
        this.facadeObject = null;
    }

    /**
     * An entity Class is the class for that the &quot;crud&quot; functionality will be created.
     */
    private Class entityClass;

    /**
     * Setting the entity Class that
     * @return the class for that the &quot;crud&quot; functionality will be created.
     */
    public Class getEntityClass() {
        return entityClass;
    }
    /**
     * Sets the class for that the &quot;crud&quot; functionality will be created.
     * @param entityClass the class for that the &quot;crud&quot; functionality will be created.
     */
    public void setEntityClass(Class entityClass) {
        this.entityClass = entityClass;
    }

    /**
     * Displayed name of the entity.
     */
    private String entityName;
    /**
     * Getting the displayed name of the entity.
     * @return displayed name of the entity
     */
    public String getEntityName() {
        return entityName;
    }
    /**
     * Setting the displayed name of the entity.
     * @param entityName displayed name of the entity
     */
    public void setEntityName(String entityName) {
        this.entityName = entityName;
    }

    /**
     * Object that have methods to handle entity
     */
    private FacadeInterface facadeObject;
    /**
     * Getting the object that have methods to handle entity.
     * @return object that have methods to handle entity
     */
    public FacadeInterface getFacadeObject() {
        return facadeObject;
    }

    /**
     * Setting the object that have methods to handle entity.
     * @param facadeObject Object that have methods to handle entity
     */
    public void setFacadeObject(FacadeInterface facadeObject) {
        this.facadeObject = facadeObject;
    }

    /**
     * List of fields one is able to edit in a formular.
     */
    private Vector<Field> editableFields;

    /**
     * Getting list of fields one is able to edit in a formular.
     * @return list of fields one is able to edit in a formular
     */
    public Vector<Field> getEditableFields() {
        return editableFields;
    }
    /**
     * Setting list of fields one is able to edit in a formular.
     * @param editableFields list of fields is able to edit in a formular
     */
    public void setEditableFields(Vector<Field> editableFields) {
        this.editableFields = editableFields;
    }

    /**
     * List of types for editable fields.
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_STRING
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_PASSWORD
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_TEXTAREA
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_INTEGER
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_DOUBLE
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_LIST
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_BOOLEAN
     */
    private Vector<Integer> editableFieldTypes;
    /**
     * Getting list of types for editable fields.
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_STRING
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_PASSWORD
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_TEXTAREA
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_INTEGER
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_DOUBLE
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_LIST
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_BOOLEAN
     * @return list of types for editable fields
     */
    public Vector<Integer> getEditableFieldTypes() {
        return editableFieldTypes;
    }
    /**
     * Setting list of types for editable fields.
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_STRING
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_PASSWORD
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_TEXTAREA
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_INTEGER
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_DOUBLE
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_LIST
     * @see de.tabuma.lib.contentmanagement.constants#TYPE_BOOLEAN
     * @param editableFieldsTyp list of types for editable fields
     */
    public void setEditableFieldTypes(Vector<Integer> editableFieldsTyp) {
        this.editableFieldTypes = editableFieldsTyp;
    }

    /**
     * Hashtable that puts the displayed name to a field of entityClass.
     * @see #entityClass
     */
    private Hashtable<Field, String> displayedName;
    /**
     * Getting hashtable that puts the displayed name to a field of entityClass.
     * @return hashtable that puts the displayed name to a field of entityClass.
     * @see #entityClass
     */
    public Hashtable<Field, String> getDisplayedName() {
        return displayedName;
    }
    /**
     * Setting hashtable that puts the displayed name to a field of entityClass.
     * @param displayedName
     * @see #entityClass
     */
    public void setDisplayedName(Hashtable<Field, String> displayedName) {
        this.displayedName = displayedName;
    }

    Vector<Field> mandatoryField;
    /**
     * Getting mandatory fields of a form.
     * @return List of mandatory fields
     */
    public Vector<Field> getMandatoryField() {
        return mandatoryField;
    }
    /**
     * Setting list of mandatory fields of a form.
     * @param mandatoryField Field list
     */
    public void setMandatoryField(Vector<Field> mandatoryField) {
        this.mandatoryField = mandatoryField;
    }
    public boolean isMandatoryField(Field field) {
        for(int i=0;i<this.mandatoryField.size();i++) {
            if(this.mandatoryField.get(i).equals(field)) {
                return true;
            }
        }
        return false;
    }
}
